// pages/auth/auth.js
import { request } from "../../request/request"
Page({

  // 获取用户的信息和code
  getUserInfo(e) {
    const { encryptedData, rawData, iv, signature } = e.detail
    // 获取小程序登录成功后的code
    const code = undefined;
    wx.login({
      success: (res) => {
        this.code = res.code;
      }
    })
    const loginParams = { encryptedData, rawData, iv, signature, code }
    // 发送请求
    const { token } = request({ url: " /users/wxlogin", data: loginParams }).then(res => {
    })
    // 把 token 值保存在 存储中并返回上一个页面
    wx.setStorageSync('token', token);
    wx.navigateBack({
      data: 1
    })
  }
})